package com.lingshi.yingzaitownmap.entity.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

import static com.lingshi.yingzaitownmap.constrants.ResultConstants.SEND_ERROR_CODE;
import static com.lingshi.yingzaitownmap.constrants.ResultConstants.SEND_SUCCESS_CODE;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> implements Serializable {

    private String msg; //信息
    private Integer code; //状态码
    private T data; //数据

    public static <T> Result<T> success(){
        return new Result<>("请求成功",SEND_SUCCESS_CODE,null);
    }

    public static <T> Result<T> success(T data){
        return new Result<>("请求成功",SEND_SUCCESS_CODE,data);
    }

    public static Result error(){
        return new Result("请求失败",SEND_ERROR_CODE,null);
    }

    public static Result error(String msg){
        return new Result(msg,SEND_ERROR_CODE,null);
    }


}
